<?php

if( isset( $_POST['what'] ) && $_POST['what'] == "xie" ){
    $num = du() + 1;
    xie($num);
    exit(  json_encode(array('res'=>1,"num"=>$num)) );
}else{
    exit( json_encode(array('res'=>1,"num"=>du())) );
}


function xie($num){
    $myfile = fopen("downloadnum.txt", "w") or die(json_encode(array('res'=>0,"msg"=>"open file error!!!")));
    $txt = $num;
    fwrite($myfile, $txt);
    fclose($myfile);
}

function du(){
    $myfile = fopen("downloadnum.txt", "r") or die(json_encode(array('res'=>0,"msg"=>"open file error!!!")));
    $num = fgets($myfile);
    fclose($myfile);
    return $num;
}



